package com.zzw.basic.classloader;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class DogInvocationHandler implements InvocationHandler {

	private Object target;
	public void setTarget(Object target) {
		this.target = target;
	}

	public DogInvocationHandler(){

	}

	public DogInvocationHandler(Object target){
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		DogUtil dogUtil = new DogUtil();
		dogUtil.method1();
		Object result = method.invoke(target,args);
		dogUtil.method2();
		System.out.println("name:" + proxy.getClass().getName());
		System.out.println("super:" + proxy.getClass().getSuperclass().getName());
		InvocationHandler invocationHandler = Proxy.getInvocationHandler(proxy);
		Class<?>[] interfaces = proxy.getClass().getInterfaces();
		return result;
	}

}
